<template>
	<view class="div">
		<view class="flet">
			<van-sidebar active-key=" 0 ">
				<van-sidebar-item @click="Button(item.bcid)" v-for="item in taBar" :key="item.bcid"
					:title="item.name" />


			</van-sidebar>
		</view>

		<view class="right">
			<van-card @tap="ahntopage(item.objectId)" v-for="item in selectlist" :key="item.objectId"
				:price="item.price" :desc="item.xiangqing" :title="item.xiangqing" :thumb="item.image"></van-card>

		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {

				taBar: [],
				list: [],
				selectlist: []
			}
		},
		onShow() {
			this.data()
			this.class()
		},

		methods: {
			data() {
				let url = `/1.1/classes/bscs`
				this.$get(url).then(res => {
					uni.stopPullDownRefresh()
					let {
						results
					} = res
					if (results.length) {
						this.selectlist = res.results
						this.list = res.results

					}

				})

			},
			class() {
				let url = `/1.1/classes/pcclass`
				this.$get(url).then(res => {
					console.log(res)
					this.taBar = res.results
				})
			},
			Button(bcid) {
				// console.log(bcid)
				
				
				this.selectlist = ''
				if (bcid === "0") {
					this.selectlist = this.list
				} else {

					this.selectlist = this.list.filter(item => {
						// console.log(item.bcid.includes(bcid))
						if (item.bcid && item.bcid.includes(bcid)) {
							return item.bcid.includes(bcid)
						}



					})

				}

				console.log(this.selectlist)

			},
			ahntopage(item) {



				
					// 用户已经登录，执行相关操作
					// console.log("一登陆")
					uni.navigateTo({
						url: `../zhanshi/zhanshi?id=` + item
					})

				


			}
		}
	}
</script>

<style>
	.div {
		display: flex;
	}

	.right {
		width: calc(100% - 80px);

		border: 1px solid black;
		margin-left: 83px;
		border-left: 0;
	}

	.flet {
		width: 80px;
		border: 1px solid black;


		position: fixed;
	}
</style>